package esercitazione3.tda_NodeList;

import esercitazione3.exceptions.InvalidPositionException;

public class DNode<E> implements Position<E> {

	private E element;
	private DNode<E> next, prev;
	
	public DNode(DNode<E> p, E e, DNode<E> n){
		prev = p;
		element = e;
		next = n;
	}
	
	public E element() throws InvalidPositionException{

		if((prev==null) || (next==null)){
			throw new InvalidPositionException("Posizione non valida");
		}
		
		return element;
	}
	
	public DNode<E> getNext(){
		return next;
	}
	
	public DNode<E> getPrev(){
		return prev;
	}
	
	public void setElement(E newElem){
		element = newElem;
	}

	public void setNext(DNode<E> newNext){
		next = newNext;
	}
	
	public void setPrev(DNode<E> newPrev){
		prev = newPrev;
	}
	
}
